package com.crape.topic.dao.impl;

import java.util.HashMap;
import java.util.Map;

import org.springframework.stereotype.Service;

import com.crape.common.exceptions.DAOException;
import com.crape.common.ibatis.SqlMapClientDaoSupportEx;
import com.crape.common.model.ArticleVisitor;
import com.crape.topic.dao.IArticleVisitorDAO;

@Service
public class ArticleVisitorDAOImpl extends SqlMapClientDaoSupportEx implements IArticleVisitorDAO {

	@Override
	public ArticleVisitor getArticleVisitor(Long visitorid, Long articleid) throws DAOException {
		if (visitorid == null || articleid == null) {
			return null;
		}
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("visitorid", visitorid);
		params.put("articleid", articleid);
		return (ArticleVisitor) this.queryObject("getArticleVisitor", params);
	}

	@Override
	public void insertArticleVisitor(Long visitorid, Long articleid) throws DAOException {
		if (visitorid == null || articleid == null) {
			return;
		}
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("visitorid", visitorid);
		params.put("articleid", articleid);
		this.insert("insertArticleVisitor", params);
	}

	@Override
	public void updateArticleVisitor(Long visitorid, Long articleid) throws DAOException {
		if (visitorid == null || articleid == null) {
			return;
		}
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("visitorid", visitorid);
		params.put("articleid", articleid);
		this.update("updateArticleVisitor", params);
	}

}
